// See background.html for more info on this regular expression.
// http://library.ci.mtnview.ca.us/search~S0?/cJ+780.92+MOZART+Stanley/cj+780.92+mozart+stanley/-3,-1,,B/browse
// It should match urls like the one above.
// starts with /c + any charaters (1+) + any number (1+) + . + any number (1+) + 
// any character except / (1+) + / + any character except /  
var regex = /\/c.*\d+\.\d+[^/]+\/[^/]/;

// Second regex case
// http://libris.ci.mtnview.ca.us/search~S0?/cY+FICTION+WREDE/cy+fiction+wrede/-3,-1,,B/browse
var regex2 = /\/c[A-Z]+\+[A-Z]+[^/]+\//;

// For all "a" (link) elements find whether any one of them matches the regular expression.
$("a").each(function() {
   if (regex.test($(this).attr("href")) || regex2.test($(this).attr("href"))) {
      // The regular expression produced a match, so notify the background page.
      chrome.extension.sendRequest({
         "url" : $(this).attr("href")
      }, function(response) {});
   }
});
